/*
 * @lc app=leetcode.cn id=75 lang=cpp
 *
 * [75] 颜色分类
 */

// @lc code=start
class Solution {
public:
    void sortColors(vector<int>& nums) {
        uint8_t color[3] = {0};

        for (auto n : nums)
            color[n]++;

        int index = 0;
        for (int i = 0; i < 3; i++, index += color[i - 1])
            for (int c = 0; c < color[i]; c++)
                nums[index + c] = i;
    }
};
// @lc code=end

